Release 10.1A: OpenEdge Development:
Programming Interfaces


Loading an XML file

The LOAD( ) method reads the specified file into memory, parses it, optionally validates it, and makes its contents available to the 4GL. Once the XML file is in memory, you must get the handle to its root element by using the GET-DOCUMENT-ELEMENT( ) method. Once you have the root node handle, you can manipulate the remaining child nodes.

The following code fragment demonstrates loading an XML file called myfile.xml:

DEFINE VARIABLE hDocMine AS HANDLE.
DEFINE VARIABLE hRootMine AS HANDLE.

CREATE X-DOCUMENT hDocMine.
CREATE X-NODEREF hRootMine.

hDocMine:LOAD("FILE","myfile.xml",TRUE).
hDocMine:GET-DOCUMENT-ELEMENT(hRootMine).
   . 
   . 
   . 

Loading an XML file from a LONGCHAR

An XML file can be read from a LONGCHAR as the following code fragment demonstrates:

DEFINE VARIABLE longstring AS LONGCHAR.
   . 
   . 
   .
hDoc:LOAD("LONGCHAR",longstring,FALSE).
   . 
   . 
   . 

Loading an XML file from a MEMPTR

An XML file can be read from a MEMPTR as the following code fragment demonstrates:

DEFINE VARIABLE memfile AS MEMPTR.
   . 
   . 
   .
FILE-INFO:FILE-NAME = "meminp.xml".
SET-SIZE(memfile) = FILE-INFO:FILE-SIZE.
INPUT FROM "meminp.xml" BINARY NO-CONVERT. 
IMPORT memfile. 
INPUT CLOSE.
hDoc:LOAD("memptr",memfile,FALSE).
   . 
   . 
   . 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095